home *** CD-ROM | disk | FTP | other *** search
/ Champak 142 / Volume 142 Oct 17 2011 - Damaged.iso / Games / operation-graduates.swf / scripts / frame_41 / DoAction_7.as < prev    next >
Text File  |  2011-10-17  |  3KB  |  105 lines

  1. function spawnSwooper(xSpot)
  2. {
  3.    var _loc1_ = enemyContainer.attachMovie("swooper","enemy" + eConCount++,eConCount);
  4.    _loc1_.gotoAndStop(1);
  5.    _loc1_._x = xSpot;
  6.    _loc1_._y = (- _loc1_._height) / 2;
  7.    _loc1_.approaching = true;
  8.    _loc1_.retreating = false;
  9.    _loc1_.energy = 20;
  10.    _loc1_.t = 0;
  11.    _loc1_.d = 40;
  12.    _loc1_.sR = _loc1_._rotation;
  13.    _loc1_.cR = 0;
  14.    _loc1_.sY = _loc1_._y;
  15.    _loc1_.cY = 300;
  16.    _loc1_.move = swooperMover;
  17.    _loc1_.Q1logic = baddyQ1;
  18.    _loc1_.Q2logic = baddyQ2;
  19.    _loc1_.Q3logic = baddyQ3;
  20.    _loc1_.Q4logic = baddyQ4;
  21.    _loc1_.hit = swooperHit;
  22.    this.isHit = false;
  23.    _loc1_.shoot = swooperShoot;
  24.    _loc1_.collide = baddyCollide;
  25. }
  26. function swooperMover()
  27. {
  28.    if(this.isHit)
  29.    {
  30.       this.resetColor();
  31.       this.isHit = false;
  32.    }
  33.    with(this)
  34.    {
  35.       if(approaching)
  36.       {
  37.          if(t < d)
  38.          {
  39.             t++;
  40.             _y = Math.easeOutQuad(t,sY,cY,d);
  41.             _rotation = Math.atan2(_y - theHull._y,_x - theHull._x) * 57.29577951308232 + 90;
  42.             if(t == d)
  43.             {
  44.                shoot(_x,_y);
  45.                this.t = 0;
  46.                this.d = 40;
  47.                this.sR = this._rotation;
  48.                this.cR = - this._rotation;
  49.                this.sY = this._y;
  50.                this.cY = -40 - this._y;
  51.                this.approaching = false;
  52.                this.retreating = true;
  53.             }
  54.          }
  55.       }
  56.       else if(retreating)
  57.       {
  58.          if(t < d)
  59.          {
  60.             t++;
  61.             _y = Math.easeInQuad(t,sY,cY,d);
  62.             _rotation = Math.easeInQuad(t,sR,cR,d);
  63.             if(t == d)
  64.             {
  65.                this.removeMovieClip();
  66.             }
  67.          }
  68.       }
  69.    }
  70. }
  71. function swooperHit()
  72. {
  73.    var _loc1_ = this;
  74.    _loc1_.setRGB(16777215);
  75.    _loc1_.isHit = true;
  76.    _loc1_.energy -= 5;
  77.    if(_loc1_.energy <= 0)
  78.    {
  79.       playSound("sound.missile.explode");
  80.       explode(_loc1_);
  81.       addScore(300);
  82.       baddyKillCount++;
  83.    }
  84. }
  85. function swooperShoot(startX, startY)
  86. {
  87.    var _loc1_ = this;
  88.    var _loc2_ = eBullets.attachMovie("eBul2","bullet" + eBulletsCount++,eBulletsCount);
  89.    playSound("sound.gun2");
  90.    _loc2_._x = startX;
  91.    _loc2_._y = startY;
  92.    _loc2_.vel = new Vector(theHull._x - startX,theHull._y - startY);
  93.    _loc2_.vel.setLength(5);
  94.    _loc2_.onEnterFrame = function()
  95.    {
  96.       var _loc1_ = this;
  97.       _loc1_._x += _loc1_.vel.x;
  98.       _loc1_._y += _loc1_.vel.y;
  99.       if(_loc1_._x < 0 || _loc1_._x > 600 || _loc1_._y < 0 || _loc1_._y > 400)
  100.       {
  101.          _loc1_.removeMovieClip();
  102.       }
  103.    };
  104. }
  105.